import BaseApi from "@/api/BaseApi.ts";
import type ISysDepartReq from "../type/req/ISysDepartReq.ts";
import type ISysDepartResp from "../type/resp/ISysDepartResp.ts";

class SysDepartApi extends BaseApi {

    constructor() {
        super("/rbac/sysDepart")
    }

    /**
     * 分页查询
     */
    tree = (departName?: string) => {
        return this.get<ISysDepartResp[], { departName: string | undefined }>('tree', {departName})
    }

    /**
     * 根据id查询数据
     */
    queryById = (id: String) => {
        return this.get('queryById', {id})
    }

    /**
     * 根据有无id新增或编辑数据
     */
    addOrUpdate = (sysDepartReq: ISysDepartReq) => {
        return this.post<string, ISysDepartReq>('addOrUpdate', sysDepartReq)
    }

    /**
     * 根据id删除数据
     */
    deleteById = (ids: string[]) => {
        return this.delete<string>('delete', ids)
    }

}

export default new SysDepartApi()